﻿<template>
  <a-modal
    :title="title"
    width="40%"
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleSubmit"
    @cancel="()=>{this.visible=false}"
  >
    <a-spin :spinning="loading">
      <a-form-model ref="form" :model="entity" :rules="rules" v-bind="layout">
        <a-form-model-item label="编号" prop="id">
          <a-input v-model="entity.id" autocomplete="off" placeholder="编号" />
        </a-form-model-item>
        <a-form-model-item label="客户编码" prop="cCusCode">
          <a-input v-model="entity.cCusCode" autocomplete="off" placeholder="客户编码" />
        </a-form-model-item>
        <a-form-model-item label="所属银行" prop="cBank">
          <a-input v-model="entity.cBank" autocomplete="off" placeholder="所属银行" />
        </a-form-model-item>
        <a-form-model-item label="开户银行" prop="cBranch">
          <a-input v-model="entity.cBranch" autocomplete="off" placeholder="开户银行" />
        </a-form-model-item>
        <a-form-model-item label="银行账号" prop="cAccountNum">
          <a-input v-model="entity.cAccountNum" autocomplete="off" placeholder="银行账号" />
        </a-form-model-item>
        <a-form-model-item label="帐号名称" prop="cAccountName">
          <a-input v-model="entity.cAccountName" autocomplete="off" placeholder="帐号名称" />
        </a-form-model-item>
        <a-form-model-item label="默认值" prop="bDefault">
          <a-input v-model="entity.bDefault" autocomplete="off" placeholder="默认值" />
        </a-form-model-item>
        <a-form-model-item label="省/自治区" prop="cCusPrinvince">
          <a-input v-model="entity.cCusPrinvince" autocomplete="off" placeholder="省/自治区" />
        </a-form-model-item>
        <a-form-model-item label="市/县" prop="cCusCity">
          <a-input v-model="entity.cCusCity" autocomplete="off" placeholder="市/县" />
        </a-form-model-item>
        <a-form-model-item label="机构号" prop="cCusCBBDepId">
          <a-input v-model="entity.cCusCBBDepId" autocomplete="off" placeholder="机构号" />
        </a-form-model-item>
        <a-form-model-item label="联行号" prop="cCusBranchId">
          <a-input v-model="entity.cCusBranchId" autocomplete="off" placeholder="联行号" />
        </a-form-model-item>
        <a-form-model-item label="联行号Ⅱ（中银专用）" prop="cCusBranchIdSec">
          <a-input v-model="entity.cCusBranchIdSec" autocomplete="off" placeholder="联行号Ⅱ（中银专用）" />
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  props: {
    parentObj: Object
  },
  data () {
    return {
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 18 }
      },
      visible: false,
      loading: false,
      entity: {},
      rules: {},
      title: ''
    }
  },
  methods: {
    init () {
      this.visible = true
      this.entity = {}
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
    },
    openForm (id, title) {
      this.init()
      this.title = title
      if (id) {
        this.loading = true
        this.$http.post('/CustomerManagement/CustomerBank/GetTheData', { id: id }).then(resJson => {
          this.loading = false

          this.entity = resJson.Data
        })
      }
    },
    handleSubmit () {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loading = true
        this.$http.post('/CustomerManagement/CustomerBank/SaveData', this.entity).then(resJson => {
          this.loading = false

          if (resJson.Success) {
            this.$message.success('操作成功!')
            this.visible = false

            this.parentObj.getDataList()
          } else {
            this.$message.error(resJson.Msg)
          }
        })
      })
    }
  }
}
</script>
